@extends('layouts.back_stage')
@section('content')
    <link href="{{env('CDN_DOMAIN_NAME')}}/store/commoncss/simplePagination.css" rel="stylesheet">
    <!-- 盘点初审详情-->
    <div class="container">
        <div style="padding:20px 0;"><h3>退货详情</h3></div>
        <table class="table table-hover">
            <thead>
            <tr>
                <th>名称</th>
                <th>日期</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <div id="paging1" class="page" style=""></div>
    </div>
    <!-- /盘点初审详情-->
    <script src="{{ env('CDN_DOMAIN_NAME') }}/store/commonjs/jquery.simplePagination.js?v0.0.3"></script>
    <script>
        /*点击分页*/
        $(document).on('click','.page-link',function(){
            if($(this).attr('class') === "page-link next nextPage"){
                if($(this).parent().attr('class') == 'active'){
                    return false;
                }else{
                    skip=Number(skip)+1;
                    pervNextSerach();
                }
            }else if($(this).attr('class') === "page-link prev prevPage"){
                if($(this).parent().attr('class') == 'active'){
                    return false;
                }else{
                    skip=Number(skip)-1;
                    pervNextSerach();
                }
            }else if($(this).attr('class') === "page-link tcdNumber"){
                skip=Number($(this).text());
                pervNextSerach();
            }
        });
        /*页面初始化*/
        var skip = 1;
        pervNextSerach();
        function pervNextSerach(){
            var shop_id = '{{$shop_id}}';
            $.ajax({
                url:'/warehouse/return-shop-details',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                dataType:'json',
                data:{
                    skip:skip,
                    shop_id:shop_id
                },
                success:function(data){
                    console.log(data);
                    if(data.result.success){
                        $('.table tbody').empty();
                        var res=data.content.content;
                        if(res.length>0){
                            for(var i in res){
                                if(res[i].is_new==-1){
                                    var status='<td>未核对</td>';
                                }else if(res[i].is_new==1){
                                    var status='<td style="color:#ccc;">已核对</td>';
                                }
                                var str='<tr>' +
                                    '<td>'+res[i].name+'</td>' +
                                    '<td>'+res[i].created_at+'</td>' +status+
                                    '<td>' +
                                    '<a href="/warehouse/return-order-lists/'+res[i].id+'">详情</a>' +
                                    '</td>' +
                                    '</tr>';
                                $('.table tbody').append(str);
                            }
                        }else{
                            $('.table tbody').append("<tr><td class='text-center' colspan='4'>无数据</td></tr>");
                        }
                        $("#paging1").pagination({
                            items: data.content.total,
                            itemsOnPage: 10,
                            cssStyle: 'light-theme',
                            currentPage:data.content.skip
                        });
                    }else{
                        $(".faceImg").attr("src","/img/weep.png");
                        $(".oHandle").text(data.result.errorMsg);
                        $(".oSuccess").show(0).delay(1000).hide(0);
                    }
                }
            });
        }
    </script>
@endsection
